# 赶集网房屋求租信息
import requests
from bs4 import BeautifulSoup
from ganjiCatch import GjBuyHouseDetail

newsurl = 'http://yangzhou.ganji.com/'
res = requests.get(newsurl + 'fang2/')
res.encoding = 'utf-8'
html_content = res.text
# 解析
soup = BeautifulSoup(html_content, 'html.parser')
# 取body
html_body = soup.select('body')[0]
# 取正文=====》可能后期会变化
for news in html_body.select('.list-noimg'):
    # 信息主题
    title = news.select('.list-title')[0].text
    # 获取连接地址
    href = newsurl + news.select('.list-title')[0].get('href')
    # 更新时间
    update = news.select('.coltime')[0].text
    # 价格
    money = news.select('.colprice')[0].text

    print('信息主题：' + title)
    print('详情链接：' + href)
    print("更新时间：" + update)
    print("期望价格:" + money)
    print('---------详情-----------')
    GjBuyHouseDetail.findDetail(href)
    print('===================================================================================================')
#     TODO 根据详情链接，获取正文信息，并且拼装
